<template>
  <div class="newsDetail">
  <myheader outerTitle="新闻详情"></myheader>
  <div>
    <h1 class="news-title">{{detailList.title}}</h1>
    <p class="news-info">
      <span>{{detailList.add_time | filterTime}}</span>
      <span>{{detailList.click}}</span>
      <span>xxx分类</span>
    </p>
  </div>
  <div class="news-content" v-html="detailList.content"></div>
  <comment :id='id'></comment>
  </div>
</template>
<script>
import myheader from '@/components/myheader'
import comment from '@/components/comment'
import { getNewsDetail } from '@/api'
export default {
  components: {
    myheader,
    comment
  },
  data () {
    return {
      detailList: {},
      id: this.$route.params.id // 专门用于保存文章的id
    }
  },
  created () {
    this.initDetailPage()
  },
  methods: {
    initDetailPage () {
      getNewsDetail(this.id)
        .then(res => {
          // console.log(res)
          this.detailList = res.message[0]
        })
    }
  }
}
</script>
<style lang="scss" scoped>
  .news-detail {
  padding: 40px 0 0 0;
  .news-title {
    font-size: 14px;
    font-weight: bold;
  }
  .news-info {
    font-size: 12px;
    color: #26a2ff;
    display: flex;
    justify-content: space-between;
  }
  .news-content {
    font-size: 12px;
  }
}
</style>
